﻿Chenxin.UI.ItemForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    id: 'frm_item',
    renderTo: 'jqmAddItem',
    actionUrl: '/service/logic/ItemsManage.ashx',
    title: '新增项目',
    op: 'add',
    scope: this,
    jqmWidth: 480,
    defBBtn: true,
    createForm: function() {
        return Chenxin.FormCommon.ItemForm(this.id);
    },
    saveSucc: function() {
        this.reloadGrid();
    },
    initFormValidator: function() {
        $("#ItemsName").formValidator({
            validatorgroup: this.id,
            onshow: "请输入项目名称！",
            onfocus: "请输入项目名称！",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "项目名称不能为空！"
            },
            onerror: "项目名称不能为空！"
        });

        $("#ItemsRegion").formValidator({
            validatorgroup: this.id,
            onshow: "请输入项目区域！",
            onfocus: "请输入项目区域！",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "项目区域不能为空！"
            },
            onerror: "项目区域不能为空！"
        });

        $("#ItemsAddress").formValidator({
            validatorgroup: this.id,
            onshow: "请输入项目地址！",
            onfocus: "请输入项目地址！",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "项目地址不能为空！"
            },
            onerror: "项目地址不能为空！"
        });
    },
    createComboList:function(){
	   var _this=this;
		//城市
        var souceCity = new Chenxin.UI.StructCombo({
            param: { op: 'getcity' },
            containerId: '#divcity',
            name: 'CityId',
            tbxWidth: 90,
            inModelType: 'all',
            txtModelName :'CityName',
            required: true,
            onSelected: function() {
                if (this.getValue() == this.defVal) {
                    souceCompany.clearItems();
                } else {
                    souceCompany.param.fatherid = this.getValue();
                    souceCompany.reload();
                }
            }
        });

        //公司
        var souceCompany = new Chenxin.UI.StructCombo({
            autoLoad: false,
            param: { op: 'getcompany' },
            containerId: '#divcompany',
            tbxWidth: 70,
            name: 'CompanyId',
            tbxWidth: 90,
            inModelType: 'all',
            required: true,
            txtModelName :'CompanyName'
        });
        return [souceCity,souceCompany];
	},
});

Chenxin.FormCommon.ItemForm = function(formID) {// height:100px;overflow:auto;
    return '<table style="width:100%;margin:5px 0px;"><tbody><tr style="line-height: 26px;"><th style="width:80px;text-align:right;">项目名称：</th><td><input style="width:120px;" name="ItemsName" class="inputbox_n fl" id="ItemsName" type="text"  /><div id="ItemsNameTip" style="float: left; margin-left: 5px; width: 121px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td><tr style="line-height: 26px;"><th style="text-align:right;">项目区域：</th><td><input style="width:120px;" name="ItemsRegion" class="inputbox_n fl" type="text" id="ItemsRegion" /><div id="ItemsRegionTip" style="float: left; margin-left: 5px; width: 121px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr style="line-height: 26px;"><th style="text-align:right;">项目地址：</th><td><input style="width:120px;" name="ItemsAddress" id="ItemsAddress" class="inputbox_n fl" type="text" /><div id="ItemsAddressTip" style="float: left; margin-left: 5px; width: 121px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div><input type="hidden" name="RecordId"/></td></tr><tr><th style="width:80px;text-align:right;">所属城市：</th><td><div id="divcity" class="SelectWrapSingle" style="z-index:2;"></div></td></tr><tr><th style="width:80px;text-align:right;">所属公司：</th><td><div id="divcompany" class="SelectWrapSingle" style="z-index:1;"></div></td></tr></tbody></table>';
}